From 4969cde6b90c426f915ec13ac682f8b191962854 Mon Sep 17 00:00:00 2001 From: Eddie Dong Date: Thu, 9 Jun 2011 16:24:09 +0800 Subject: [PATCH] Nested VMX: Emulation of guest VMPTRST Signed-off-by: Qing He Signed-off-by: Eddie Dong Acked-by: Tim Deegan Committed-by: Tim Deegan --- xen/arch/x86/hvm/vmx/vmx.c | 6 +++++- xen/arch/x86/hvm/vmx/vvmx.c | 22 ++++++++++++++++++++++ xen/include/asm-x86/hvm/vmx/vvmx.h | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index cbd847910e..574a6a2f2e 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2444,11 +2444,15 @@ asmlinkage void vmx_vmexit_handler(struct cpu_user_regs *regs) update_guest_eip(); break; + case EXIT_REASON_VMPTRST: + if ( nvmx_handle_vmptrst(regs) == X86EMUL_OKAY ) + update_guest_eip(); + break; + case EXIT_REASON_MWAIT_INSTRUCTION: case EXIT_REASON_MONITOR_INSTRUCTION: case EXIT_REASON_VMCLEAR: case EXIT_REASON_VMLAUNCH: - case EXIT_REASON_VMPTRST: case EXIT_REASON_VMREAD: case EXIT_REASON_VMRESUME: case EXIT_REASON_VMWRITE: diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c index ab5718f5b5..12004cb849 100644 --- a/xen/arch/x86/hvm/vmx/vvmx.c +++ b/xen/arch/x86/hvm/vmx/vvmx.c @@ -456,3 +456,25 @@ out: return X86EMUL_OKAY; } +int nvmx_handle_vmptrst(struct cpu_user_regs *regs) +{ + struct vcpu *v = current; + struct vmx_inst_decoded decode; + struct nestedvcpu *nvcpu = &vcpu_nestedhvm(v); + unsigned long gpa = 0; + int rc; + + rc = decode_vmx_inst(regs, &decode, &gpa, 0); + if ( rc != X86EMUL_OKAY ) + return rc; + + gpa = nvcpu->nv_vvmcxaddr; + + rc = hvm_copy_to_guest_virt(decode.mem, &gpa, decode.len, 0); + if ( rc != HVMCOPY_okay ) + return X86EMUL_EXCEPTION; + + vmreturn(regs, VMSUCCEED); + return X86EMUL_OKAY; +} + diff --git a/xen/include/asm-x86/hvm/vmx/vvmx.h b/xen/include/asm-x86/hvm/vmx/vvmx.h index 70d2b3374a..fbe34ab034 100644 --- a/xen/include/asm-x86/hvm/vmx/vvmx.h +++ b/xen/include/asm-x86/hvm/vmx/vvmx.h @@ -154,6 +154,7 @@ void __set_vvmcs(void *vvmcs, u32 vmcs_encoding, u64 val); void nvmx_destroy_vmcs(struct vcpu *v); int nvmx_handle_vmptrld(struct cpu_user_regs *regs); +int nvmx_handle_vmptrst(struct cpu_user_regs *regs); #endif /* __ASM_X86_HVM_VVMX_H__ */ -- 2.30.2